From dad25249a0fbba820e2de070f912e371e72e4fd8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 30 Aug 2022 10:36:42 -0700 Subject: save account settings --- src/routes/[username]/settings/+page.svelte | 57 ++++++++++++++++--------- src/routes/[username]/settings/_account.svelte | 26 +++++++++-- src/routes/[username]/settings/_security.svelte | 4 +- 3 files changed, 60 insertions(+), 27 deletions(-) (limited to 'src/routes/[username]/settings') diff --git a/src/routes/[username]/settings/+page.svelte b/src/routes/[username]/settings/+page.svelte index 1d162ef2..c6d7d3c0 100644 --- a/src/routes/[username]/settings/+page.svelte +++ b/src/routes/[username]/settings/+page.svelte @@ -5,6 +5,8 @@ import { AppHeader, Icon } from '$comp'; import { t } from '$lib/translations'; + import { failure, success, put } from '$lib/utils'; + import { user } from '$lib/store'; let tab = 'account'; @@ -15,29 +17,42 @@ ]; $: ({ comp } = tabs.find((t) => t.name === tab)); + + let save = async () => { + try { + await put('/user', $user); + success('Settings saved'); + } catch (e) { + failure('Something went wrong'); + } + }; -
-

- {$t('user.settings.header')} -

- -
- {#each tabs as { name, key }} - - {/each} +
+
+

+ {$t('user.settings.header')} +

+ +
+ {#each tabs as { name, key }} + + {/each} +
+ +
- - -
- -
- -
+
+ +
+ diff --git a/src/routes/[username]/settings/_account.svelte b/src/routes/[username]/settings/_account.svelte index 2ce78554..68af0841 100644 --- a/src/routes/[username]/settings/_account.svelte +++ b/src/routes/[username]/settings/_account.svelte @@ -3,9 +3,9 @@ import { Icon, Toggle, LocaleSelector } from '$comp'; import { t } from '$lib/translations'; - let password; let selectedTheme = 1; let revealPassword = false; + let password; const colorThemes = [ { theme: 1, color1: 'from-[#F5F7FA]', color2: 'to-[#C3CFE2]' }, @@ -15,6 +15,13 @@ { theme: 5, color1: 'from-[#F3E7E9]', color2: 'to-[#E3EEFF]' }, { theme: 6, color1: 'from-[#F5F7FA]', color2: 'via-[#EAF2FF] to-[#DEDFFF]' } ]; + + const handleThemeClick = (colors) => { + selectedTheme = colors.theme; + $colorTheme = colors.color1 + ' ' + colors.color2; + }; + + $: $user.password = $user.confirm = password;
@@ -24,7 +31,12 @@
- +
@@ -32,7 +44,7 @@
@@ -55,7 +67,12 @@
- +
@@ -83,6 +100,7 @@

{$t('user.settings.themeDescription')}

{#each colorThemes as colors}
@@ -32,7 +32,7 @@

{$t('user.settings.twofaDescription')}

-
-- cgit v1.2.3